package com.example.owner;

import com.example.owner.db.Owner;
import com.example.owner.service.OwnerService;
import io.micronaut.data.model.Page;
import io.micronaut.data.model.Pageable;
import jakarta.inject.Singleton;

@Singleton
public class PetOwnerCliClient {

    private final OwnerService ownerService;

    public PetOwnerCliClient(OwnerService ownerService) {
        this.ownerService = ownerService;
    }

    protected void performFindAll() {
        Page<Owner> pOwners =
                ownerService.findAll(Pageable.unpaged());
    }

    protected Owner performSave() {
        Owner owner = initOwner();
        return ownerService.save(owner);
    }

    private Owner initOwner() {
        Owner owner = new Owner();
        owner.setFirstName("Foo");
        owner.setLastName("Bar");
        owner.setCity("Toronto");
        owner.setAddress("404 Adelaide St W");
        owner.setTelephone("647000999");
        return owner;
    }
}
